<template>
  <div class="login-phone">
    <el-form :model="phone" :rules="rules">
      <el-form-item label="手机号" prop="num">
        <el-input v-model="phone.num" />
      </el-form-item>
      <el-form-item label="验证码" prop="code">
        <div class="get-code">
          <el-input v-model="phone.code" />
          <el-button type="primary" class="get-btn">获取验证码</el-button>
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>

<script lang="ts">
import { defineComponent, reactive } from 'vue';
import { useStore } from 'vuex';

import { rules } from '../config/phone-config';

export default defineComponent({
  setup() {
    const store = useStore();

    const phone = reactive({
      num: '',
      code: ''
    });

    const loginAction = () => {
      console.log('手机号登录逻辑在此~');

      store.dispatch('login/phoneLoginAction', { ...phone });
    };

    return {
      phone,
      rules,
      loginAction
    };
  }
});
</script>

<style scoped lang="less">
.get-code {
  display: flex;

  .get-btn {
    margin-left: 8px;
  }
}
</style>
